//
//  AdvertisingDetailViewController.m
//  小汽车
//
//  Created by 邹壮壮29 on 15-1-3.
//  Copyright (c) 2015年 蓝欧科技. All rights reserved.
//

#import "AdvertisingDetailViewController.h"
#import "MainPageBase.h"
#import "AdvertisingModel.h"
@interface AdvertisingDetailViewController ()<UIImagePickerControllerDelegate>

@end

@implementation AdvertisingDetailViewController
- (void)dealloc
{
    [_webSite release];
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createWebView];
    UIImage *image = [UIImage imageNamed:@"collection"];
    UIImage *newImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:newImage style:UIBarButtonItemStylePlain target:self action:@selector(collection)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(fanhui:)];
    //[self snow];
}
-(void)fanhui:(id)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)collection{
    //存入数据库
    NSString *str = [MainPageBase insertIntoMainPageAdvertising:[AdvertisingModel advertisingWithTitle:_webTitle newsLink:_webSite]];
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
    [alert show];
}
-(void)createWebView{
    UIWebView *web = [[UIWebView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    NSURL *url = [NSURL URLWithString:self.webSite];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [web loadRequest:request];
    [self.view addSubview:web];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
